//
//  Number9Cell.m
//  7.13苏宁框架
//
//  Created by mini on 15/7/16.
//  Copyright (c) 2015年 lovena. All rights reserved.
//

#import "Number9Cell.h"
#import "GoodStoryModel.h"
#import "Common.h"

@implementation Number9Cell

-(instancetype)init
{
    self = [super init];
    if (self) {
        self = [[[NSBundle mainBundle]loadNibNamed:@"Number9Cell" owner:nil options:nil]lastObject];
    }
    return self;
}
- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    
}

-(void)layoutSubviews
{
    [super layoutSubviews];
    self.scrollView.pagingEnabled = NO;
    self.scrollView.decelerationRate = 0.2;
    self.scrollView.delegate = self;
    [self addImages];
}

-(void)addImages
{
    _total = [NSArray array];
    _total = [GoodStoryModel modelArrayWithFilename:@"goodStory.plist"];
    int x = 0;
    for (int i = 0; i < _total.count; i++) {
        UIImageView *image = [[UIImageView alloc]init];
        image.frame = CGRectMake(x, 0, 110, self.scrollView.height);
        _model = _total[i];
        [image setImageWithURL:[NSURL URLWithString:_model.icon]];
        UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(0, image.bottom -20, image.width, 20)];
        label.text = _model.name;
        [label setTextColor:[UIColor whiteColor]];
        label.backgroundColor = [UIColor grayColor];
        label.alpha = 0.8;
        [self.scrollView addSubview:image];
        [image addSubview:label];
        x = x +112;
    }
    self.scrollView.contentSize = CGSizeMake(x, 0);
   self.scrollView.showsHorizontalScrollIndicator = NO;
    self.scrollView.bounces = NO;
}
@end
